#!/bin/bash
source $(dirname "$0")/.triton.conf
netcheckcmd="curl ${triton_ping_addr} | grep "百度一下" | wc -l"
netok=$(eval $netcheckcmd) 
if [ $netok -lt 1 ];then
    curl "http://${triton_host}/user-login-auth" \
    -H 'Accept: application/json, text/javascript, */*; q=0.01' \
    -H 'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6' \
    -H 'Cache-Control: no-cache' \
    -H 'Connection: keep-alive' \
    -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
    -H "Origin: http://${triton_host}" \
    -H 'Pragma: no-cache' \
    -H "Referer: http://${triton_host}/login" \
    -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0' \
    -H 'X-Requested-With: XMLHttpRequest' \
    --data-urlencode "param%5BUserName%5D=${triton_userName}" \
    --data-urlencode "param%5BUserPswd%5D=${triton_password}" \
    --data-urlencode "uri=id=&url=&user=&mac=" \
    --data-urlencode "force=1" \
    --insecure -i     
else
   echo 'network ok'
fi
